home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / pyxmpp / sasl / gssapi.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  53 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. __revision__ = '$Id$'
  5. __docformat__ = 'restructuredtext en'
  6. import base64
  7. import kerberos
  8. import logging
  9. from pyxmpp.sasl.core import ClientAuthenticator, Failure, Response, Challenge, Success
  10.  
  11. class GSSAPIClientAuthenticator(ClientAuthenticator):
  12.     
  13.     def __init__(self, password_manager):
  14.         ClientAuthenticator.__init__(self, password_manager)
  15.         self.password_manager = password_manager
  16.         self._GSSAPIClientAuthenticator__logger = logging.getLogger('pyxmpp.sasl.gssapi.GSSAPIClientAuthenticator')
  17.  
  18.     
  19.     def start(self, username, authzid):
  20.         self.username = username
  21.         self.authzid = authzid
  22.         if not authzid:
  23.             pass
  24.         (rc, self._gss) = kerberos.authGSSClientInit('%s@%s' % ('xmpp', self.password_manager.get_serv_host()))
  25.         self.step = 0
  26.         return self.challenge('')
  27.  
  28.     
  29.     def challenge(self, challenge):
  30.         if self.step == 0:
  31.             rc = kerberos.authGSSClientStep(self._gss, base64.b64encode(challenge))
  32.             if rc != kerberos.AUTH_GSS_CONTINUE:
  33.                 self.step = 1
  34.             
  35.         elif self.step == 1:
  36.             rc = kerberos.authGSSClientUnwrap(self._gss, base64.b64encode(challenge))
  37.             response = kerberos.authGSSClientResponse(self._gss)
  38.             rc = kerberos.authGSSClientWrap(self._gss, response, self.username)
  39.         
  40.         response = kerberos.authGSSClientResponse(self._gss)
  41.         if response is None:
  42.             return Response('')
  43.         else:
  44.             return Response(base64.b64decode(response))
  45.  
  46.     
  47.     def finish(self, data):
  48.         self.username = kerberos.authGSSClientUserName(self._gss)
  49.         self._GSSAPIClientAuthenticator__logger.debug('Authenticated as %s' % kerberos.authGSSClientUserName(self._gss))
  50.         return Success(self.username, None, self.authzid)
  51.  
  52.  
  53.